#include "common.h"

// 典型循环递归
class Solution {
public:
    int maxDepth(TreeNode *root) {
        int depth;
        int depthLeft;
        int depthRight;
        
        if(!root)
        {
            depth = 0;
        }
        else
        {
            depthLeft = maxDepth(root->left);
            depthRight = maxDepth(root->right);
            depth = 1 + (depthLeft > depthRight ? depthLeft : depthRight);
        }
        return depth;
    }
};